public class TestComplex {
    public static void main(String[] args) {
        // 测试构造函数
        Complex c1 = new Complex();
        Complex c2 = new Complex(3.0, 4.0);

        // 测试 getReal 和 getImag 方法
        System.out.println("c1 的实部: " + c1.getReal());
        System.out.println("c1 的虚部: " + c1.getImag());
        System.out.println("c2 的实部: " + c2.getReal());
        System.out.println("c2 的虚部: " + c2.getImag());

        // 测试 setReal 和 setImag 方法
        c1.setReal(5.0);
        c1.setImag(6.0);
        System.out.println("设置后 c1 的实部: " + c1.getReal());
        System.out.println("设置后 c1 的虚部: " + c1.getImag());

        // 测试 setValue 方法
        c2.setValue(7.0, 8.0);
        System.out.println("设置后 c2 的实部: " + c2.getReal());
        System.out.println("设置后 c2 的虚部: " + c2.getImag());

        // 测试 toString 方法
        System.out.println("c1: " + c1.toString());
        System.out.println("c2: " + c2.toString());

        // 测试 isReal 和 isImaginary 方法
        System.out.println("c1 是实数吗? " + c1.isReal());
        System.out.println("c1 是纯虚数吗? " + c1.isImaginary());
        System.out.println("c2 是实数吗? " + c2.isReal());
        System.out.println("c2 是纯虚数吗? " + c2.isImaginary());

        // 测试 equals 方法
        Complex c3 = new Complex(7.0, 8.0);
        System.out.println("c2 和 c3 相等吗? " + c2.equals(c3));
        System.out.println("c2 和 (5.0, 6.0) 相等吗? " + c2.equals(5.0, 6.0));

        // 测试 abs 方法
        System.out.println("c1 的模: " + c1.abs());
        System.out.println("c2 的模: " + c2.abs());

        // 测试 add 方法
        Complex c4 = c1.add(c2);
        System.out.println("c1 + c2 = " + c4.toString());

        // 测试 substract 方法
        Complex c5 = c1.substract(c2);
        System.out.println("c1 - c2 = " + c5.toString());

        // 测试 multiply 方法
        Complex c6 = c1.multiply(c2);
        System.out.println("c1 * c2 = " + c6.toString());

        // 测试 divide 方法
        Complex c7 = new Complex(1.0, 0.0);
        Complex c8 = new Complex(2.0, 0.0);
        Complex c9 = c7.divide(c8);
        System.out.println("c7 / c8 = " + c9.toString());

        // 测试输入 NaN 的情况
        Complex nanComplex1 = new Complex(Double.NaN, 1.0);
        Complex nanComplex2 = new Complex(1.0, Double.NaN);
        nanComplex1.setReal(Double.NaN);
        nanComplex2.setImag(Double.NaN);
        nanComplex1.setValue(Double.NaN, Double.NaN);
        System.out.println("测试含有 NaN 的情况已完成，具体提示信息见上述输出");
    }
}
